// components/grid/index.js
Component({
  options: {
    multipleSlots: !0
  },
  externalClasses: ["l-class", "extra-grid-class"],
  /**
   * 组件的属性列表
   */
  properties: {
    grids: {
      type: Array,
      value: [],
      observer: function (val) {
        if (val.length > 0) {
          this.setData({
            gridItems: val
          })
        }
      }
    },
    rowNum: {
      type: String,
      value: 3
    },
    showBorder: Boolean,
    showColBorder: Boolean,
    showRowBorder: Boolean
  },

  /**
   * 组件的初始数据
   */
  data: {
    gridItems: [],
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onTapImage(e) {
      let index = e.currentTarget.dataset.gridIndex;
      let urls = new Array();
      this.data.gridItems.forEach(e => {
        urls.push(e.url)
      })
      wx.previewImage({
        current: this.data.gridItems[index].url, // 当前显示图片的http链接
        urls: urls // 需要预览的图片http链接列表
      })
    }
  }
})